<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div>
        <!--工具栏-->
        <!-- 搜索 -->
        <el-input v-model="query.akb020" clearable size="small" placeholder="服务机构编号" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-input v-model="query.insuNo" clearable size="small" placeholder="拨付机构编号" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-select v-model="query.cjt100" clearable size="small" placeholder="参保类型" class="filter-item" style="width: 120px" @change="crud.toQuery">
          <el-option
            v-for="item in cblxTypeOptions"
            :key="item.key"
            :label="item.display_name"
            :value="item.key"
          />
        </el-select>
        <el-date-picker v-model="query.aae001" type="year" value-format="yyyy" format="yyyy" placeholder="年度" class="filter-item" />
        <rrOperation :crud="crud" />
        <el-button
          :loading="crud.downloadLoading"
          :disabled="!crud.data.length"
          class="filter-item"
          size="mini"
          type="warning"
          icon="el-icon-download"
          @click="crud.doExport"
        >导出</el-button>
      </div>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="aae002Ks" label="统筹区" align="center" />
        <el-table-column prop="akb020" label="服务机构编号" align="center" width="100px" />
        <el-table-column prop="akb021" label="服务机构名称" align="center" width="300px" />
        <el-table-column prop="aae001" label="年度" align="center" />
        <el-table-column prop="cjt100" label="参保类型" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.cjt100 === '0'">
              职工
            </span>
            <span v-else>
              居民
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="aae140" label="照护类型" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.aae140 === '9'">
              机构
            </span>
            <span v-else>
              居家
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="akb065" label="医疗费总额" align="center" width="100px" />
        <el-table-column prop="akb066" label="个人帐户金额" align="center" width="100px" />
        <el-table-column prop="akb067" label="个人现金金额" align="center" width="100px" />
        <el-table-column prop="akb068" label="统筹支付金额" align="center" width="100px" />
        <el-table-column prop="akb090" label="预留总金额" align="center" width="100px" />
        <el-table-column prop="akb071" label="年底考核扣款金额" align="center" width="100px" />
        <el-table-column prop="akb094" label="应支付金额总计" align="center" width="120px" />
        <el-table-column prop="insuNo" label="拨付机构代码" align="center" width="100px" />
        <el-table-column prop="inusName" label="拨付机构名称" align="center" width="300px" />
        <el-table-column prop="akb083" label="年度评分" align="center" width="250px" />
        <el-table-column prop="id" label="总计" align="center" width="220px" />
        <el-table-column fixed="right" label="操作" width="200px" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="toOpen1(scope.row)"
            >预 览</el-button>
            <el-button
              size="mini"
              type="primary"
              @click="toDetail(scope.row)"
            >查看明细</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
      <!-- 打印拨付单 -->
      <printKb04View ref="printKb04View" />
      <!-- 拨付单明细 -->
      <sbIndexDetail ref="sbIndexDetail" />
    </div>
  </div>
</template>

<script>
import printKb04View from '../kb04/printKb04View'
import sbIndexDetail from '../kb03/sbIndexDetail'
import crudPggs from '@/api/business/pggs'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import moment from 'moment'

const defaultForm = { aae002: null }
export default {
  name: 'Pggs',
  components: { pagination, crudOperation, rrOperation, udOperation, printKb04View, sbIndexDetail },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['ccs'],
  cruds() {
    return CRUD({ title: '照护拨付单', url: 'api/generalQuery/queryNewKb04', idField: 'id', sort: ['akb020,asc', 'cjt100,asc', 'aae140,desc', 'insuNo,asc', 'aab034,asc'], crudMethod: { ...crudPggs }})
  },
  data() {
    return {
      value2: '',
      cblxTypeOptions: [
        { key: '0', display_name: '职工' },
        { key: '1', display_name: '居民' }
      ],
      zhlbTypeOptions: [
        { key: '9', display_name: '机构' },
        { key: '10', display_name: '居家' }
      ],
      permission: {
        add: ['admin', 'pggs:add'],
        edit: ['admin', 'pggs:edit'],
        del: ['admin', 'pggs:del']
      },
      rules: {
        bisGsglQymc: [
          { required: true, message: '企业名称不能为空', trigger: 'blur' }
        ],
        bisGsglTyshxydm: [
          { required: true, message: '统一社会信用代码不能为空', trigger: 'blur' }
        ],
        bisGsglLxr: [
          { required: true, message: '联系人不能为空', trigger: 'blur' }
        ],
        bisGsglLxrdh: [
          { required: true, message: '联系人电话不能为空', trigger: 'blur' }
        ],
        bisGsglSsqx: [
          { required: true, message: '所属区县不能为空', trigger: 'blur' }
        ],
        bisGsglZcdz: [
          { required: true, message: '注册地址不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'bisGsglQymc', display_name: '企业名称' },
        { key: 'bisGsglTyshxydm', display_name: '统一社会信用代码' },
        { key: 'bisGsglLxr', display_name: '联系人' },
        { key: 'bisGsglLxrdh', display_name: '联系人电话' },
        { key: 'bisGsglSsqx', display_name: '所属区县' },
        { key: 'bisGsglZcdz', display_name: '注册地址' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    linstensing(d) {
      // query.aae002
      const date1 = moment(d).format('YYYY') - 1
      console.log(date1)
      this.query.aae001 = date1
      return date1
    },
    toOpen1(row) {
      console.log(row)
      this.$refs.printKb04View.printViewDialog = true
      this.$refs.printKb04View.dataValue = row
      this.$refs.printKb04View.tempAae001 = row.aae001
      this.$refs.printKb04View.tempCjt100 = row.cjt100 === '0' ? '职工' : '居民'
      this.$refs.printKb04View.queryPrintKb04()
    },
    toDetail(row) {
      console.log(row)
      const tempCjt100 = row.cjt100
      const tempAae001 = row.aae140 === '9' ? '1' : '2'
      this.$refs.sbIndexDetail.detailDialog = true
      this.$refs.sbIndexDetail.akb020 = row.akb020
      this.$refs.sbIndexDetail.aae002 = row.aae001
      this.$refs.sbIndexDetail.cjt100 = tempCjt100
      this.$refs.sbIndexDetail.aaa022 = tempAae001
      this.$refs.sbIndexDetail.aab034 = row.aab034
      console.log(this.$refs.sbIndexDetail)
      this.$refs.sbIndexDetail.crud.toQuery()
    }
  }
}
</script>

<style scoped>

</style>
